#include "sv2_video_saver.h"
#include <cmath>
#include <fstream>
#ifdef WITH_GSTREAMER
#include "writer_gstreamer_impl.h"
#endif

namespace sv2 {

VideoWriter::VideoWriter()
{
#ifdef WITH_GSTREAMER
  this->_gstreamer_impl = new VideoWriterGstreamerImpl;
#endif
}
VideoWriter::~VideoWriter()
{
}

bool VideoWriter::setupImpl(std::string file_name_)
{
  cv::Size img_sz = this->getSize();
  double fps = this->getFps();
  std::string file_path = this->getFilePath();

#ifdef WITH_GSTREAMER
  return this->_gstreamer_impl->gstreamerSetup(this, file_name_);
#endif
  return false;
}

bool VideoWriter::isOpenedImpl()
{
#ifdef WITH_GSTREAMER
  return this->_gstreamer_impl->gstreamerIsOpened();
#endif
  return false;
}

void VideoWriter::writeImpl(cv::Mat img_)
{
#ifdef WITH_GSTREAMER
  this->_gstreamer_impl->gstreamerWrite(img_);
#endif
}

void VideoWriter::releaseImpl()
{
#ifdef WITH_GSTREAMER
  this->_gstreamer_impl->gstreamerRelease();
#endif
}

}

